﻿using System.Drawing;
using System.Windows.Forms;

namespace SimpleTerminal.Render
{
    // class MyMenuRender : ToolStripProfessionalRenderer
    class ToolStripSimpleRender : ToolStripSystemRenderer
    {
        protected override void OnRenderToolStripBackground(ToolStripRenderEventArgs e)
        {
            base.OnRenderToolStripBackground(e);

        }

        protected override void OnRenderItemImage(ToolStripItemImageRenderEventArgs e)
        {
            base.OnRenderItemImage(e);
        }

        protected override void OnRenderImageMargin(ToolStripRenderEventArgs e)
        {
            base.OnRenderImageMargin(e);
            //e.Graphics.FillRectangle(new SolidBrush(SystemColors.Control),e.AffectedBounds);
        }

        protected override void OnRenderMenuItemBackground(ToolStripItemRenderEventArgs e)
        {
            //if (e.Item.Enabled)
            //    base.OnRenderMenuItemBackground(e);
            if (e.Item.Enabled && e.Item.Selected)
            {
                e.Graphics.FillRectangle(new SolidBrush(SystemColors.ControlLight),
                    new Rectangle(0, 0, e.Item.Width, e.Item.Height));
            }
            else
            {
                e.Graphics.FillRectangle(new SolidBrush(Color.White),
                    new Rectangle(0, 0, e.Item.Width, e.Item.Height));
            }
        }
        /// <summary>
        /// 渲染菜单项的分隔线
        /// </summary>
        /// <param name="e"></param>
        protected override void OnRenderSeparator(ToolStripSeparatorRenderEventArgs e)
        {
            e.Graphics.DrawLine(new Pen(Color.FromArgb(200, 200, 200), 1), e.ToolStrip.Padding.Left,
                e.Item.Height / 2, e.Item.Width, e.Item.Height / 2);
        }

        protected override void OnRenderItemText(ToolStripItemTextRenderEventArgs e)
        {
            if (e.Item.Selected||e.Item.Pressed)
            {
                e.TextColor = Color.Black;
            }
            base.OnRenderItemText(e);
        }

        protected override void OnRenderArrow(ToolStripArrowRenderEventArgs e)
        {
            e.ArrowColor = Color.Black;
            base.OnRenderArrow(e);
            //e.
        }

        //  protected override 

        protected override void OnRenderToolStripBorder(ToolStripRenderEventArgs e)
        {
            base.OnRenderToolStripBorder(e);
            // e.Graphics.DrawRectangle(new Pen(Color.FromArgb(0xcc, 0xcc, 0xcc), 1),e.AffectedBounds);
        }
    }
}
